import Vue from 'vue'
import Vuex from 'vuex'
import commonModules from '@/common/store'

import productCategoryModule from '@/credit/store/modules/productCategory'

Vue.use(Vuex)

const files = require.context('./modules/', true, /\.js$/)
const appModules = files.keys().reduce((mod, path) => {
  const name = path.replace(/\.\/(\S+)\.js$/, '$1')
  mod[name] = files(path).default
  return mod
}, {})

export default new Vuex.Store({
  modules: {
    ...appModules,
    ...commonModules,
    productCategoryModule,
  },
  strict: process.env.NODE_ENV !== 'production',
})
